﻿using RRQMXml;
using System.IO;

namespace LocalDbControler
{
    public class AppConfig
    {
        public AppConfig(string path)
        {
            if (File.Exists(path))
            {
                XmlTool xml = new XmlTool(path);
                ServiceIP = xml.SearchWords("ServiceIP", "value");
                FileServicePort = xml.SearchNumber("FileServicePort", "value");
                RPCServicePort = xml.SearchNumber("RPCServicePort", "value");
            }
            else
            {
                XmlTool xml = new XmlTool(path);
                xml.AttributeStorage("ServiceIP", "value", "127.0.0.1");
                xml.AttributeStorage("FileServicePort", "value", "7789");
                xml.AttributeStorage("RPCServicePort", "value", "7790");
            }
        }

        public  string ServiceIP { get; set; }
        public  int FileServicePort { get; set; }
        public  int RPCServicePort { get; set; }
    }
}